﻿@model OnlineItemViewModel

<script type="text/javascript">
	var msgsF = [];
    @foreach (VideoSeller.Business.Data.CultureResource file in Html.GetResources("Flash"))
	{
      <text>msgsF["@file.ResourceName"] = '@file.ResourceValue';</text>
	}
	if (AC_FL_RunContent == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	}
</script>
@{
	var removedSetup = false;

	var wApp = "noapp";
	var extPar = "";
	var iUser = !Model.IsAnonymous;
	var iOwner = iUser && (Model.Author.UserId == Model.CurrentUserId);

	var iPublisher =
		iOwner
		&& (Model.OnlineContentType == VideoSeller.Business.Data.Enums.OnlineContentType.Announcement || Model.OnlineContentType == VideoSeller.Business.Data.Enums.OnlineContentType.Online);
	var iReader = !iPublisher;
	var showContent = true;
	var confPStyle = "";
	var cModelName = Model.Id.ToString();
	var cModelPName = cModelName;
	var cModelCName = cModelName + "_";
	var vieversFull = false;
	if (Model.Price > 0 && !Model.IsPaid && !iOwner)
	{
		showContent = false;
	}
	if (Model.VideoContentType == VideoSeller.Business.Data.Enums.VideoContentType.Free)
	{
		wApp = "VSLive";
	}
	if (Model.VideoContentType == VideoSeller.Business.Data.Enums.VideoContentType.Paid)
	{
		wApp = "Conference";
		iReader = iUser && !iPublisher;
		if (!iPublisher)
		{
			confPStyle = "style=display:none;";
			cModelPName += "_";
		}
		iPublisher = true;

	}
	if (Model.UsePassword && !iOwner)
	{
		if (!iOwner)
		{ extPar += "pn=1&amp;"; }
	}
	if (!iOwner && wApp == "Conference")
	{
		extPar += "ap=1&amp;";
	}
	if (Model.VideoContentType == VideoSeller.Business.Data.Enums.VideoContentType.PaidGroups)
	{
		wApp = "MeetingClosed";
		iPublisher = true;
		iReader = false;
		extPar += "pn=1&amp;";
	}
	if (iReader && (Model.Price > 0 && !Model.IsPaid))
	{
		iReader = false;
	}
	var _xd = "1280";
	var _yd = "960";
	var c640 = "";
	var c640x = "";
	if (wApp == "VSLive")
	{
		c640 = "xy_640x480";
		c640x = "xy_640x480x";
	}
	var pApp = wApp;
	if (wApp == "VSLive" && iReader)
	{
		vieversFull = Model.maxViewers <= Model.currentViewers;
		wApp = "Balancer";
		//wApp = "VSLive";
	}
	//wApp = Model.WowzaPath + wApp;
	pApp = Model.WowzaPath + pApp;
	extPar += "BS=1&amp;";
	var noMoney = false;
	if (iOwner && Model.neenMoney > 0)
	{
		if (Model.Author.Finance.Total < Model.neenMoney)
		{
			noMoney = true;
		}

	}
	if (iOwner && iPublisher)
	{
		extPar += "cpr=" + Model.qualityString + "&amp;";
	}
}
<script type="text/jscript">
    currenContent = '@wApp';
    campars = '@Model.qualityString';
</script>
@if (!iUser && !wApp.Contains("Balancer"))
{
	<div class="registerOnlyMsg">@Html.GetGlobalResource("Common", "registerOnlyMsg")</div>
}
@if (iReader && showContent)
{
	<div id="MaxConBlock" style="display: none;" class="registerOnlyMsg">@Html.GetGlobalResource("Common", "vieversFullMsg")</div>
}
<div id="flashContent">
	@if (iReader && showContent)
 {
		<div id="rdrPlDiv" class="flashDiv @c640x ">
			<div class="live_container">
				<label class="play_msg" id="live1_msg"></label>
				<div class="live-player @c640">
					<script type="text/jscript">
						if (AC_FL_RunContent != 0) {
							addonlineplayer('live1', '@pApp', 'u=@Model.CurrentUserId&s=@Model.CurrentSessionId&i=@cModelName&@extPar');
					    }
					</script>
				</div>
				<div id="live1_bott_panel" class="live_bt_panel">
					<div id="live1_stopbtn" class="stop_btn" title="Stop video" onclick='liveplay("live1","stop");' style="display: none;"></div>
					<div id="live1_playbtn" class="play_btn" title="Play video" onclick='liveplay("live1","play");' style="display: none;"></div>
				</div>
			</div>
		</div>
		
 }

	@if (iPublisher && showContent)
 {
		<div id ="conf_pub_div" @confPStyle class="flashDiv @c640x">

			<div class="publish_container">
				@if (iOwner || pApp != "VSLive")
	{
					<label class="play_msg" id="meet_msg" onclick='$("#ifotdiv").show(); $("#meet_msg").hide()'>@Html.GetGlobalResource("Flash", "OpenPubBPlayer")</label>
					<div id="ifotdiv" class="play_msg" style="display: none;">
						<input type="text" id="contentDscInp" class="play_msg_input" maxlength="64" />
						<button class="vs_btn" type="button" onclick= '$("#ifotdiv").hide(); $("#meet_msg").show(); setContentDsc("@Model.Id"); return false;'>Ok</button>
						<button class="vs_btn" type="button" onclick='$("#ifotdiv").hide(); $("#meet_msg").show(); return false;'>Cancel</button>
					</div>
	}
	else
	{
					<label class="play_msg" id="meet_msg">@Html.GetGlobalResource("Flash", "OpenPubBPlayer")</label>
	}
				<div id="meet_flashdiv" class="pub-player  @c640">
					<script type="text/jscript">
						if (AC_FL_RunContent != 0) {
							addppublicator('meet', '@pApp', 'u=@Model.CurrentUserId&s=@Model.CurrentSessionId&i=@cModelPName&@extPar');
					    }
					</script>
				</div>
				<div id="meet_bott_panel" class="publish_bt_panel">
					@if (iOwner || wApp != "Conference")
	 {
						<div id="meet_publish" title='@Html.GetGlobalResource("Flash", "StartPublishBtnTitle")' class="publish_btn"  style="display: none;" onclick="publishCamera('meet','@Model.Id.ToString()');"></div>
						<div id="meet_unpublish" title='@Html.GetGlobalResource("Flash", "PausePublishBtnTitle")' class="publish_btn_off" style="display: none;" onclick='unpublishCamera("meet");'></div>
                     
	 }
					@if (iOwner)
	 {
						<div id="cancelPublishing" title='@Html.GetGlobalResource("Flash", "CancelPublishBtnTitle")' class="stop_btn" style="display: none;" onclick='cancelPublishing("@Model.Id.ToString()");'></div>
	 }
					@if (removedSetup)
	 {
						<div id="meet_settings_btn" class="setup_btn" style="position: relative;" onclick="chDisplay('camPresets'); ">
							<div id="camPresets" class="camPresetsBlock" style="display: none;">
								<label>@Html.GetGlobalResource("Flash", "Presets"):</label>
								@foreach (var camparam in Model.AllCamParams)
		{
									<a onclick="sendCamParam('meet','@camparam.Value','camPresets'); return false;">@Html.GetGlobalResource("Flash", @camparam.KeyName)</a>
		}

							</div>
						</div>
	 }
					<div id='meet_camera_param' class="cam_resolution_show"></div>

				</div>
				<div style="clear: both;"></div>
			</div>
			@if (removedSetup)
   {

				<div id="meet_settings" style="display: none;">
					<div class="publish_container publish_props">
						<div class="pub_param_div">
							<div class="cam-param">Camera mode</div>
							<span class="cam-param">
								<label for="meet_cwidth">Size: </label>
								<input id="meet_cwidth" title="Horizontal resolution" class="cam-param-input" type="text" maxlength="4" value="@_xd" />
								<label for="meet_cheight">x</label><input id="meet_cheight" class="cam-param-input" type="text" maxlength="4" value="@_yd" />
								<label for="meet_cfps">Fps:</label><input id="meet_cfps" class="cam-param-input" type="text" maxlength="2" value="15" />
							</span>
							<div style="clear: both;"></div>
							<div class="apply_btn" onclick="camera_applyMode('meet');"></div>
							<div class="cam-param">
								<label for="meet_fwa">Favor Area</label><input id="meet_fwa" type="checkbox" checked="checked" />
							</div>
							<div style="clear: both;"></div>
						</div>
					</div>
					<div class="publish_container publish_props">
						<div class="pub_param_div">
							<div class="cam-param">Quality: </div>
							<span class="cam-param">
								<label for="">Bandwidth: </label>
								<input id="meet_bw" title="Bandwidth. 0(auto) 1...16 " class="cam-param-input" type="text" maxlength="2" value="0" />
								<label for="meet_fq">FrameQuality: </label>
								<input id="meet_fq" title="Frame quality. 0(auto) 1(min quality, best performance) ... 100 (max quality)" class="cam-param-input" type="text" maxlength="3" value="80" />
							</span>
							<div style="clear: both;"></div>
							<div class="apply_btn" title="Apply quality" onclick="camera_applyQuality('meet');"></div>
							<div class="cam-param">
								<label for="">KeyFrame:</label><input id="meet_kfi" title="KeyFrame interval 1(best quality)...48(best performance)" class="cam-param-input" type="text" maxlength="2" value="15" />
							</div>
							<div style="clear: both;"></div>
						</div>
					</div>
				</div>
   }
			@if (!iOwner && wApp == "Conference")
   {
				<button id="btnConfSwitchPub" type="button" class="btnSwitchConf" title='@Html.GetGlobalResource("Common", "confChangeModeToPlayTitle")'  onclick="switchConf(); return false;">@Html.GetGlobalResource("Common", "confChangeModeToPlay")</button>
   }


		</div>
		
 }
	@if (showContent && wApp == "Meeting" && iUser && removedSetup)
 {
	 for (int i = 1; i < Model.TeamCount; i++)
	 {
		<div class="flashDiv">
			<div class="live_container">
				<label class="play_msg" @string.Format("id='meeting_pl_{0}_msg'", i)>Wait for member... </label>
				<div class="live-player">
					<script type="text/jscript">
						addonlineplayer('meeting_pl_@i.ToString()', '@pApp', 'u=@Model.CurrentUserId&s=@Model.CurrentSessionId&i=@cModelName&@extPar');
					</script>
				</div>
				<div id="meeting_pl_@i.ToString()_bott_panel" class="live_bt_panel">
					<div id="meeting_pl_@i.ToString()_stopbtn" class="stop_btn" title="Stop video" onclick='liveplay("meeting_pl_@i.ToString()","stop");' style="display: none;"></div>
					<div id="meeting_pl_@i.ToString()_playbtn" class="play_btn" title="Play video" onclick='liveplay("meeting_pl_@i.ToString()","play");' style="display: none;"></div>
				</div>
				<div style="clear: both;"></div>
			</div>

			<div style="clear: both;"></div>

		</div>
            
	 }
 }
	@if (showContent && wApp == "Conference" && iUser)
 { 
        
		<div id="conf_player_div" class="flashDiv">
			<div class="live_container">
				<label class="play_msg" id="live1C_msg"></label>
				<div class="live-player">
					@if (iOwner)
	 {
						<script type="text/jscript">

							if (AC_FL_RunContent != 0) {
								addonlineplayer('live1C', '@pApp', 'u=@Model.CurrentUserId&s=@Model.CurrentSessionId&i=@cModelCName');
						}
						</script>
	 }
	 else
	 {
						<script type="text/jscript">

							if (AC_FL_RunContent != 0) {
								addonlineplayer('live1C', '@pApp', 'u=@Model.CurrentUserId&s=@Model.CurrentSessionId&i=@cModelCName&pn=1&amp;');
					    }
						</script>
	 }
				</div>
				<div id="live1C_bott_panel" class="live_bt_panel">
					<div id="live1C_stopbtn" class="stop_btn" title="Stop video" onclick='liveplay("live1C","stop");' style="display: none;"></div>
					<div id="live1C_playbtn" class="play_btn" title="Play video" onclick='liveplay("live1C","play");' style="display: none;"></div>
				</div>

			</div>
			<div style="clear: both;"></div>
			@if (!iOwner && wApp == "Conference")
   {
				<button type="button" id="btnConfSwitchPlay" class="btnSwitchConf" title='@Html.GetGlobalResource("Common", "confChangeModeToPublishTitle")'  
              onclick="switchConf(); return false;">@Html.GetGlobalResource("Common", "confChangeModeToPublish")</button>
   }

		</div>
        
        
     
 }

	<div style="clear: both;"></div>

</div>
@if (iOwner)
{
	<div id="confirm-cancel-msg"  title= '@Html.GetGlobalResource("Flash", "ConfirmTitle")'>
		<div class="warningmsg">@Html.GetGlobalResource("Flash", "ConfirmCancelPublishMsg")</div>
	</div>
	<div id="confirm-publish-msg"  title= '@Html.GetGlobalResource("Flash", "ConfirmTitle")'>
		@if (Model.neenMoney == 0)
  {
			<div class="warningmsg">@Html.GetGlobalResource("Flash", "ConfirmStartPublishMsg")</div>
  }
  else
  {
	  if (noMoney)
	  {
			<div class="warningmsg">@Html.GetGlobalResource("Flash", "DisablePublishNoMoney")@Html.GetCurrencyString(Model.neenMoney)</div>
	  }
	  else
	  {
			<div class="warningmsg">@Html.GetGlobalResource("Flash", "ConfirmStartPublishMsgMoney")@Html.GetCurrencyString(Model.neenMoney)</div>
	  }

  }
	</div>

	<script type="text/javascript">
		firstpublish = 1;
		function cancelPublishing(onlineContentId) {
			$("#confirm-cancel-msg").dialog('open');
		}
		$("#confirm-publish-msg").dialog({
			autoOpen: false,
			height: 300,
			width: 500,
			modal: true,
			buttons: [
				{
					text: "@Html.GetGlobalResource("Flash", "FlashOkBtnText")",
            	click: function () {
            		
            		$(this).dialog("close");
					@if (noMoney == false)
	 {
         <text>
         firstpublish = 0;
		 	publishCamera('meet', '@Model.Id.ToString()');</text>
	 }
            	}
            },
            {
            	text: "@Html.GetGlobalResource("Flash", "FlashCancelBtnText")",
            	click: function () {
            		$(this).dialog("close");
            	}
            }
    	]


    });

	$("#confirm-cancel-msg").dialog({
		autoOpen: false,
		height: 300,
		width: 500,
		modal: true,
		buttons: [
            {
            	text: '@Html.GetGlobalResource("Flash", "FlashOkBtnText")',
            	click: function () {
            		confcancelPublishing('@Model.Id');
                }
            },
            {
            	text: '@Html.GetGlobalResource("Flash", "FlashCancelBtnText")',
            	click: function () {
            		$(this).dialog("close");
            	}
            }
        ]


    });

	</script>
}